.class public Les/tj;
.super Ljava/lang/Object;
.source "ThumbnailFactory.java"


# static fields
.field private static e:Les/tj;


# instance fields
.field private a:Lcom/estrongs/fs/f;

.field private b:Landroid/content/Context;

.field private c:Ljava/lang/String;

.field private d:Ljava/lang/String;


# direct methods
.method protected constructor <init>(Landroid/content/Context;)V
    .locals 0

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 2
    iput-object p1, p0, Les/tj;->b:Landroid/content/Context;

    .line 3
    invoke-direct {p0}, Les/tj;->b()V

    .line 4
    invoke-direct {p0}, Les/tj;->a()V

    .line 5
    invoke-static {p1}, Lcom/estrongs/fs/f;->a(Landroid/content/Context;)Lcom/estrongs/fs/f;

    move-result-object p1

    iput-object p1, p0, Les/tj;->a:Lcom/estrongs/fs/f;

    return-void
.end method

.method private static a(Landroid/graphics/BitmapFactory$Options;I)I
    .locals 3

    .line 45
    iget v0, p0, Landroid/graphics/BitmapFactory$Options;->outWidth:I

    .line 46
    iget p0, p0, Landroid/graphics/BitmapFactory$Options;->outHeight:I

    .line 47
    div-int v1, v0, p1

    .line 48
    div-int v2, p0, p1

    .line 49
    invoke-static {v1, v2}, Ljava/lang/Math;->max(II)I

    move-result v1

    const/4 v2, 0x1

    if-gt v1, v2, :cond_0

    return v2

    :cond_0
    if-le v1, v2, :cond_1

    if-le v0, p1, :cond_1

    .line 50
    div-int/2addr v0, v1

    if-ge v0, p1, :cond_1

    add-int/lit8 v1, v1, -0x1

    :cond_1
    if-le v1, v2, :cond_2

    if-le p0, p1, :cond_2

    .line 51
    div-int/2addr p0, v1

    if-ge p0, p1, :cond_2

    add-int/lit8 v1, v1, -0x1

    :cond_2
    if-gt v1, v2, :cond_3

    return v2

    :cond_3
    return v1
.end method

.method private a(Ljava/lang/String;Landroid/graphics/BitmapFactory$Options;ILjava/io/InputStream;)Landroid/graphics/Bitmap;
    .locals 3
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/estrongs/fs/FileSystemException;
        }
    .end annotation

    .line 11
    invoke-direct {p0, p1, p4}, Les/tj;->a(Ljava/lang/String;Ljava/io/InputStream;)Landroid/os/MemoryFile;

    move-result-object p4

    if-eqz p4, :cond_0

    .line 12
    invoke-virtual {p4}, Landroid/os/MemoryFile;->getInputStream()Ljava/io/InputStream;

    move-result-object v0

    goto :goto_0

    .line 13
    :cond_0
    invoke-direct {p0, p1}, Les/tj;->a(Ljava/lang/String;)Ljava/io/InputStream;

    move-result-object v0

    :goto_0
    const/4 v1, 0x0

    if-nez v0, :cond_1

    return-object v1

    .line 14
    :cond_1
    invoke-virtual {v0}, Ljava/io/InputStream;->markSupported()Z

    move-result v2

    if-eqz v2, :cond_2

    const/high16 v2, 0x200000

    .line 15
    invoke-virtual {v0, v2}, Ljava/io/InputStream;->mark(I)V

    :cond_2
    const/4 v2, 0x1

    .line 16
    iput-boolean v2, p2, Landroid/graphics/BitmapFactory$Options;->inJustDecodeBounds:Z

    .line 17
    invoke-static {v0, v1, p2}, Landroid/graphics/BitmapFactory;->decodeStream(Ljava/io/InputStream;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;

    .line 18
    invoke-virtual {v0}, Ljava/io/InputStream;->markSupported()Z

    move-result v2

    if-eqz v2, :cond_3

    .line 19
    :try_start_0
    invoke-virtual {v0}, Ljava/io/InputStream;->reset()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_1

    :catch_0
    move-exception v2

    .line 20
    invoke-virtual {v2}, Ljava/io/IOException;->printStackTrace()V

    .line 21
    :try_start_1
    invoke-virtual {v0}, Ljava/io/InputStream;->close()V
    :try_end_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_1

    .line 22
    :catch_1
    invoke-direct {p0, p1}, Les/tj;->a(Ljava/lang/String;)Ljava/io/InputStream;

    move-result-object v0

    goto :goto_1

    .line 23
    :cond_3
    :try_start_2
    invoke-virtual {v0}, Ljava/io/InputStream;->close()V
    :try_end_2
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_2

    .line 24
    :catch_2
    invoke-direct {p0, p1}, Les/tj;->a(Ljava/lang/String;)Ljava/io/InputStream;

    move-result-object v0

    .line 25
    :goto_1
    invoke-static {p2, p3}, Les/tj;->a(Landroid/graphics/BitmapFactory$Options;I)I

    move-result p1

    iput p1, p2, Landroid/graphics/BitmapFactory$Options;->inSampleSize:I

    const/4 p1, 0x0

    .line 26
    iput-boolean p1, p2, Landroid/graphics/BitmapFactory$Options;->inJustDecodeBounds:Z

    .line 27
    invoke-static {v0, v1, p2}, Landroid/graphics/BitmapFactory;->decodeStream(Ljava/io/InputStream;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;

    move-result-object p1

    if-eqz v0, :cond_4

    .line 28
    :try_start_3
    invoke-virtual {v0}, Ljava/io/InputStream;->close()V
    :try_end_3
    .catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_3

    goto :goto_2

    :catch_3
    nop

    :cond_4
    :goto_2
    if-eqz p4, :cond_5

    .line 29
    invoke-virtual {p4}, Landroid/os/MemoryFile;->close()V

    :cond_5
    if-nez p1, :cond_6

    .line 30
    iget-object p1, p0, Les/tj;->b:Landroid/content/Context;

    invoke-virtual {p1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object p1

    const p2, 0x7f0803db

    invoke-static {p1, p2}, Landroid/graphics/BitmapFactory;->decodeResource(Landroid/content/res/Resources;I)Landroid/graphics/Bitmap;

    move-result-object p1

    :cond_6
    return-object p1
.end method

.method private a(Ljava/lang/String;Ljava/io/InputStream;)Landroid/os/MemoryFile;
    .locals 7
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/estrongs/fs/FileSystemException;
        }
    .end annotation

    const/4 v0, 0x0

    .line 31
    :try_start_0
    iget-object v1, p0, Les/tj;->a:Lcom/estrongs/fs/f;

    invoke-virtual {v1, p1}, Lcom/estrongs/fs/f;->d(Ljava/lang/String;)Lcom/estrongs/fs/e;

    move-result-object v1

    if-eqz v1, :cond_3

    .line 32
    iget-wide v2, v1, Lcom/estrongs/fs/e;->d:J

    const-wide/16 v4, 0x0

    cmp-long v6, v2, v4

    if-lez v6, :cond_4

    .line 33
    new-instance v2, Landroid/os/MemoryFile;

    iget-wide v3, v1, Lcom/estrongs/fs/e;->d:J

    long-to-int v1, v3

    invoke-direct {v2, p1, v1}, Landroid/os/MemoryFile;-><init>(Ljava/lang/String;I)V

    const/16 v1, 0x2000

    new-array v3, v1, [B

    if-nez p2, :cond_0

    .line 34
    iget-object v4, p0, Les/tj;->a:Lcom/estrongs/fs/f;

    invoke-virtual {v4, p1}, Lcom/estrongs/fs/f;->e(Ljava/lang/String;)Ljava/io/InputStream;

    move-result-object p2

    .line 35
    :cond_0
    instance-of p1, p2, Ljava/io/BufferedInputStream;

    if-nez p1, :cond_1

    .line 36
    new-instance p1, Ljava/io/BufferedInputStream;

    invoke-direct {p1, p2, v1}, Ljava/io/BufferedInputStream;-><init>(Ljava/io/InputStream;I)V

    move-object p2, p1

    .line 37
    :cond_1
    invoke-virtual {p2, v3}, Ljava/io/InputStream;->read([B)I

    move-result p1

    const/4 v1, 0x0

    const/4 v4, 0x0

    :goto_0
    if-lez p1, :cond_2

    .line 38
    invoke-virtual {v2, v3, v1, v4, p1}, Landroid/os/MemoryFile;->writeBytes([BIII)V

    add-int/2addr v4, p1

    .line 39
    invoke-virtual {p2, v3}, Ljava/io/InputStream;->read([B)I

    move-result p1

    goto :goto_0

    .line 40
    :cond_2
    invoke-virtual {p2}, Ljava/io/InputStream;->close()V

    move-object v0, v2

    goto :goto_1

    .line 41
    :cond_3
    new-instance p1, Ljava/io/IOException;

    invoke-direct {p1}, Ljava/io/IOException;-><init>()V

    throw p1
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    :catchall_0
    move-exception p1

    .line 42
    invoke-virtual {p1}, Ljava/lang/Throwable;->printStackTrace()V

    .line 43
    :try_start_1
    invoke-virtual {p2}, Ljava/io/InputStream;->close()V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    :catch_0
    :cond_4
    :goto_1
    return-object v0
.end method

.method public static a(Landroid/content/Context;)Les/tj;
    .locals 1

    .line 1
    sget-object v0, Les/tj;->e:Les/tj;

    if-nez v0, :cond_1

    if-nez p0, :cond_0

    const/4 p0, 0x0

    return-object p0

    .line 2
    :cond_0
    new-instance v0, Les/tj;

    invoke-direct {v0, p0}, Les/tj;-><init>(Landroid/content/Context;)V

    sput-object v0, Les/tj;->e:Les/tj;

    .line 3
    :cond_1
    sget-object p0, Les/tj;->e:Les/tj;

    return-object p0
.end method

.method private a(Ljava/lang/String;)Ljava/io/InputStream;
    .locals 1
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/estrongs/fs/FileSystemException;
        }
    .end annotation

    .line 44
    iget-object v0, p0, Les/tj;->a:Lcom/estrongs/fs/f;

    invoke-virtual {v0, p1}, Lcom/estrongs/fs/f;->e(Ljava/lang/String;)Ljava/io/InputStream;

    move-result-object p1

    return-object p1
.end method

.method private a()V
    .locals 3

    .line 4
    iget-object v0, p0, Les/tj;->b:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getCacheDir()Ljava/io/File;

    move-result-object v0

    const-string v1, ".apps"

    const/4 v2, 0x0

    invoke-static {v0, v1, v2}, Lcom/estrongs/android/util/h0;->a(Ljava/io/File;Ljava/lang/String;Z)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Les/tj;->d:Ljava/lang/String;

    return-void
.end method

.method private b()V
    .locals 3

    .line 1
    iget-object v0, p0, Les/tj;->b:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getCacheDir()Ljava/io/File;

    move-result-object v0

    const-string v1, ".thumbnails"

    const/4 v2, 0x0

    invoke-static {v0, v1, v2}, Lcom/estrongs/android/util/h0;->a(Ljava/io/File;Ljava/lang/String;Z)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Les/tj;->c:Ljava/lang/String;

    return-void
.end method


# virtual methods
.method public a(ILjava/lang/String;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
    .locals 1

    const/4 v0, 0x0

    .line 5
    invoke-virtual {p0, p1, p2, p3, v0}, Les/tj;->a(ILjava/lang/String;Landroid/graphics/BitmapFactory$Options;Ljava/io/InputStream;)Landroid/graphics/Bitmap;

    move-result-object p1

    return-object p1
.end method

.method public a(ILjava/lang/String;Landroid/graphics/BitmapFactory$Options;Ljava/io/InputStream;)Landroid/graphics/Bitmap;
    .locals 1

    if-nez p3, :cond_0

    .line 6
    new-instance p3, Landroid/graphics/BitmapFactory$Options;

    invoke-direct {p3}, Landroid/graphics/BitmapFactory$Options;-><init>()V

    :cond_0
    const/4 v0, 0x0

    .line 7
    :try_start_0
    invoke-direct {p0, p2, p3, p1, p4}, Les/tj;->a(Ljava/lang/String;Landroid/graphics/BitmapFactory$Options;ILjava/io/InputStream;)Landroid/graphics/Bitmap;

    move-result-object p1
    :try_end_0
    .catch Ljava/lang/OutOfMemoryError; {:try_start_0 .. :try_end_0} :catch_1
    .catch Lcom/estrongs/fs/FileSystemException; {:try_start_0 .. :try_end_0} :catch_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 8
    invoke-static {p4}, Lcom/estrongs/fs/util/f;->a(Ljava/io/Closeable;)V

    return-object p1

    :catchall_0
    move-exception p1

    invoke-static {p4}, Lcom/estrongs/fs/util/f;->a(Ljava/io/Closeable;)V

    .line 9
    throw p1

    .line 10
    :catch_0
    invoke-static {p4}, Lcom/estrongs/fs/util/f;->a(Ljava/io/Closeable;)V

    return-object v0

    :catch_1
    invoke-static {p4}, Lcom/estrongs/fs/util/f;->a(Ljava/io/Closeable;)V

    return-object v0
.end method
